﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using WpfClient.NorthwindServiceReference;

namespace WpfClient
{
	/// <summary>
	/// Interaction logic for OrderWindow.xaml
	/// </summary>
	public partial class OrderWindow : Window
	{
		public String CustomerId { get; set; }

		public OrderWindow()
		{
			InitializeComponent();
		}

		private void btnCancel_Click(object sender, RoutedEventArgs e)
		{
			Close();
		}

		private void btnOk_Click(object sender, RoutedEventArgs e)
		{
			var context = (NorthwindEntities) Application.Current.Properties["context"];
			var order = new Order()
			            	{
								CustomerID = CustomerId,
								OrderDate = dtOrder.SelectedDate,
								RequiredDate = dtRequired.SelectedDate
			            	};
			context.AddToOrders(order);
			Close();
		}
	}
}
